/**
 * 获取用户操作系统
 * @returns 操作系统名称
 */
export const getUserOsInfo = (): string => {
    const userAgent = navigator.userAgent;
    if (userAgent.indexOf("Windows NT 10.0") !== -1) return "Windows 10";
    if (userAgent.indexOf("Windows NT 6.2") !== -1) return "Windows 8";
    if (userAgent.indexOf("Windows NT 6.1") !== -1) return "Windows 7";
    if (userAgent.indexOf("Windows NT 6.0") !== -1) return "Windows Vista";
    if (userAgent.indexOf("Windows NT 5.1") !== -1) return "Windows XP";
    if (userAgent.indexOf("Windows NT 5.0") !== -1) return "Windows 2000";
    if (userAgent.indexOf("Mac") !== -1) return "Mac/iOS";
    if (userAgent.indexOf("X11") !== -1) return "UNIX";
    if (userAgent.indexOf("Linux") !== -1) return "Linux";
    return "Other";
}


/** 解析web的favicon */
export const findWebFavicon = (url: string): Promise<string | undefined> => {
    return new Promise((resolve) => {
        try {
            const urlObj = new URL(url);
            resolve(`${urlObj.origin}/favicon.ico`);
        } catch (error) {
            resolve(undefined);
        }
    });
};
